// pages/mine/index.js
const App = getApp();
const app = App.globalData
import { getuserinfo,loginTest } from '../../api/index'
import {upUser,getUser} from '../../api/user'
import {myTest} from '../../api/loadData'
Page({
  data: {
    // islogin: app.isLogin,
    islogin: true,
    userInfo: { name: '政务预约', mobile: '1332345432'},
  },

  onLoad: function (options) {
    // if (app.isLogin) {
    //   this.getInfo()
    // } else {
    //   wx.navigateTo({ url: '/pages/index/login/index' })
    // }
    // myTest().then((res)=>{
    //   console.log(res)
    // })
    this.getInfo()
  },
  getInfo() {
    getUser({}).then((res) => {
      wx.stopPullDownRefresh()
      this.setData({ userInfo: res.datas })
    })
  },
  toLoginTest(){
    loginTest({}).then((res) => {
      //console.log(res);
      wx.showToast({
        icon: 'none',
        title: res.data.message,
        success: () => {
          reject(res.data)
        }
      })
    })
  },
  gologin() {
    wx.navigateTo({ url: '/pages/index/login/index' })
  },
  gopage(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.url
    })
  },
  onShow: function () {
    if (app.isReload) {
      app.isReload = false
      this.onLoad()
    }
    this.setData({
      islogin: app.isLogin,
    })
  },
  onPullDownRefresh: function () {
    this.onLoad()
  },
  printTest() {
  },
})